﻿package mortal.game.view.guildNew.WareHourse
{
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.cache.guild.module.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.pageSelect.*;

    public class GuildNewWareHRight2 extends GSprite
    {
        protected var _tOpr:GTextFiled;
        protected var _tAdon:GTextFiled;
        protected var _tGood:GTextFiled;
        protected var _tman:GTextFiled;
        protected var _list:GTileList;
        protected var _sortUpBtn:GLoadedButton;
        protected var _pageSelecter:PageSelecter;

        public function GuildNewWareHRight2()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._tOpr = UIFactory.gTextField("" + Language.getString(71648), 264, 39, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._tAdon = UIFactory.gTextField("" + Language.getString(71649), 139, 39, 55, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._tGood = UIFactory.gTextField("" + Language.getString(71650), 207, 39, 30, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._tman = UIFactory.gTextField("" + Language.getString(71651), 36, 39, 30, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._list = UIFactory.tileList(3, 56, 335, 384, this);
            this._list.direction = GBoxDirection.VERTICAL;
            this._list.verticalGap = 1;
            this._list.horizontalGap = 2;
            this._list.rowHeight = 48;
            this._list.columnWidth = 320;
            this._list.columnCount = 1;
            this._list.rowCount = 8;
            this._list.width = 335;
            this._list.setStyle("cellRenderer", GuildNewWareHCell2);
            this._sortUpBtn = UIFactory.gLoadedButton(ImagesConst.ascendingSortBtn_upSkin, 171, 43, 11, 14, this);
            this._sortUpBtn.label = "";
            this._pageSelecter = UIFactory.pageSelecter(99, 447, this, PageSelecter.CompleteMode);
            this._pageSelecter.setbgStlye(ImagesConst.ComboBg, GlobalStyle.textFormatBai.center());
            this._pageSelecter.maxPage = 1;
            this._pageSelecter.pageTextBoxSize = 36;
            this._pageSelecter.configEventListener(Event.CHANGE, this.onPageChange);
            this._sortUpBtn.visible = false;
            this.update();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tOpr = null;
            this._tAdon = null;
            this._tGood = null;
            this._tman = null;
            this._list = null;
            this._sortUpBtn = null;
            this._pageSelecter = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function updataList() : void
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.guild.selfGuildInfo.wareHouse;
            var _loc_3:* = this._list.rowCount * this._list.columnCount;
            var _loc_4:* = (this._pageSelecter.currentPage - 1) * _loc_3;
            var _loc_5:* = _loc_4 + _loc_3;
            var _loc_6:* = _loc_4;
            while (_loc_6 < _loc_5)
            {
                
                if (_loc_6 < _loc_2.allApplyList.length)
                {
                    _loc_1.addItem(_loc_2.allApplyList[_loc_6]);
                }
                _loc_6++;
            }
            if (_loc_1.length == 0 && this._pageSelecter.currentPage > 1)
            {
                (this._pageSelecter.currentPage - 1);
                this.updataList();
                return;
            }
            this._list.dataProvider = _loc_1;
            this._list.drawNow();
            var _loc_7:* = Cache.instance.guild.selfGuildInfo.wareHouse.allApplyList.length;
            this._pageSelecter.maxPage = Math.ceil(_loc_7 / this._list.rowCount * this._list.columnCount);
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            this.updataList();
            return;
        }// end function

        public function update() : void
        {
            this.updataList();
            return;
        }// end function

    }
}
